package cn.wolfcode.crm.domain;

import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Customer {
    public static final int CUSTOM_POTENTIAL = 0;//潜在客户
    public static final int CUSTOM_NORMAL = 1;//正式客户
    public static final int CUSTOM_FAIL = 2;//失败客户
    public static final int CUSTOM_LOST = 3;//流失客户
    public static final int CUSTOM_POOL = 4;//客户池
    //客户id
    private Long id;
    //姓名
    private String name;
    //年龄
    private Integer age;
    //性别
    private Integer gender;
    //电话
    private String tel;
    //qq
    private String qq;
    //职业
    private SystemDictionaryItem job;
    //来源
    private SystemDictionaryItem source;
    //销售人员
    private Employee seller;
    //录入人员
    private Employee inputuser;
    //录入时间
    private Date inputTime;
    //状态
    private Integer status = CUSTOM_POTENTIAL;

    //获取状态名字
    public String getStatusName() {
        String StatusName = "潜在客户";
        switch (status) {
            case CUSTOM_NORMAL:
                StatusName = "正式客户";
                break;
            case CUSTOM_FAIL:
                StatusName = "失败客户";
                break;
            case CUSTOM_LOST:
                StatusName = "流失客户";
                break;
            case CUSTOM_POOL:
                StatusName = "客户池";
                break;
        }
        return StatusName;
    }

    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("name", name);
        map.put("age", age);
        map.put("gender", gender);
        map.put("tel", tel);
        map.put("qq", qq);
        if (job != null) {
            map.put("jobId", job.getId());
        }
        if (source != null) {
            map.put("sourceId", source.getId());
        }
        if (seller != null) {
            map.put("sellerId", seller.getId());
            map.put("sellerName", seller.getName());
        }
        return JSON.toJSONString(map);
    }
}